﻿using System.Collections.Generic;
using System.IO;

namespace VirtualDeveloper
{
    internal class FileAdapter : IFileAdapter
    {
        public IEnumerable<string> GetFiles(string directory, string filter)
        {
            return Directory.GetFiles(directory, filter, SearchOption.AllDirectories);
        }

        public void SaveToFile(string file, string newContent)
        {
            using (var stream = File.Open(file, FileMode.Create, FileAccess.Write))
            using (var writer = new StreamWriter(stream))
            {
                writer.Write(newContent);
            }
        }

        public string ReadAllText(string file)
        {
            return File.ReadAllText(file);
        }
    }
}